#include "polarcoordinates.h"

#include <cmath>

using namespace std;


PolarCoordinates::PolarCoordinates(double rad, double angle) : rad(rad), angle(angle) {
    checkInput();
}

pair<double, double> PolarCoordinates::getDecartCoordinates() const {
    return make_pair(rad * cos(angle), rad * sin(angle));
}

void PolarCoordinates::setAngle(double angle) {
    if (angle < 0 || angle > 360) {
        throw wrongAngle;
    }
    this->angle = angle;
}

double PolarCoordinates::getAngle() const {
    return angle;
}

void PolarCoordinates::setRadius(double rad) {
    if (rad < 0) {
        throw wrongRad;
    }
    this->rad = rad;
}

double PolarCoordinates::getRadius() const {
    return rad;
}

void PolarCoordinates::checkInput() {
    if (rad < 0 || angle < 0 || angle > 360) {
        throw wrongData;
    }
}

